Coffee ratings



This is my first Tidy Tuesday contribution and will be playing around a little bit with the the Coffee rating data .

Libraries

tidyverse: data transformations and beautiful plots (Wickham et al. 2019).
hrbrthemes: this contains the ipsum theme, a very simple and elegant theme (Rudis 2020).
rmarkdown: all the structure of the report relies on this library (Allaire et al. 2020).
bookdown: allows the bibliography on the YAML header of this Rmarkdown doc (Xie 2016, 2020a).
epuRate: the elegant theme of the report (Holtz 2020).
knitr: all parts integration to render the output reporducible report (Xie 2014, 2015, 2020b).
citr: addin for easyly find citations in the .bib file and insert in the correct format (Aust 2019).
ggsci: a set of scientific palettes library and more… (Xiao 2018).
icon inserting many different icons in markdown (O’Hara-Wild 2020).


Getting Tidy Tuesday data

data <-  tidytuesdayR::tt_load(2020, week = 28)
  
    Downloading file 1 of 1: `coffee_ratings.csv`
coffee <- data$coffee_ratings
head(coffee)

Coffee ratings distribution

p1 <- coffee %>% 
  drop_na(any_of("country_of_origin")) %>%
  filter(aroma != 0) %>% 
  ggplot() +
  aes(x = total_cup_points, fill = country_of_origin) +
  geom_density() +
  theme_minimal() +
  scale_fill_viridis_d(alpha = 0.7) +
  ylab("Proportion of coffes per country") +
  xlab("Total cup points") +
  theme(
    plot.title = element_text(size = 18, face = "bold"),
    axis.title.x = element_text(size = 16),
    axis.title.y = element_text(size = 16),
    axis.text.y = element_text(size = 16),
    legend.text = element_text(size = 14),
    legend.title = element_blank(),
    legend.position = "bottom"
  ) 
  
p2 <- coffee %>% 
  drop_na(any_of("country_of_origin")) %>%
  filter(aroma != 0) %>% 
  ggplot() +
  aes(x = total_cup_points, y = country_of_origin, fill = country_of_origin) +
  geom_boxplot(show.legend = FALSE) +
  theme_minimal() +
  scale_fill_viridis_d(alpha = 0.7) +
  ylab("Countries") +
  xlab("Total cup points") +
  labs(fill = "Country") +
  theme(
    plot.title = element_text(size = 18, face = "bold"),
    axis.title.x = element_text(size = 16),
    axis.title.y = element_text(size = 16),
    axis.text.y = element_text(size = 18)
  ) +
  gghighlight(country_of_origin == "Colombia")


p2 / p1 + plot_annotation(tag_levels = 'A')



References




Allaire, JJ, Yihui Xie, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, Hadley Wickham, Joe Cheng, Winston Chang, and Richard Iannone. 2020. Rmarkdown: Dynamic Documents for R. https://CRAN.R-project.org/package=rmarkdown.

Aust, Frederik. 2019. Citr: RStudio Add-in to Insert Markdown Citations. https://CRAN.R-project.org/package=citr.

Holtz, Yan. 2020. EpuRate: A Clean Template for R Markdown Documents.

O’Hara-Wild, Mitchell. 2020. Icon: SVG Icons for R Documents and Apps. https://github.com/mitchelloharawild/icon.

Rudis, Bob. 2020. Hrbrthemes: Additional Themes, Theme Components and Utilities for ’Ggplot2’. https://CRAN.R-project.org/package=hrbrthemes.

Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain Fran??ois, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.

Xiao, Nan. 2018. Ggsci: Scientific Journal and Sci-Fi Themed Color Palettes for ’Ggplot2’. https://CRAN.R-project.org/package=ggsci.

Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.

———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.

———. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.

———. 2020a. Bookdown: Authoring Books and Technical Documents with R Markdown. https://CRAN.R-project.org/package=bookdown.

———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R. https://CRAN.R-project.org/package=knitr.

 




A work by Camilo Garcia